const api=require("../../api/index.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    types:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.loadHotFilms();
    this.loadLatestFilms();
  },
  doSearch(e){
    wx.navigateTo({
      url: `/pages/collection/collection?q=${e.detail.value}&name='${e.detail.value}' 电影列表`,
    })
  },

  //热门电影
  async loadHotFilms(){
      let res=await api.loadHotFilms();
      // console.log(res);
      let type={
        title:res.data.subject_collection.name,
        list:res.data.subject_collection_items,
        funName:"loadHotFilms"
      };

      this.setData({
          "types[0]":type
      });
  },
  async loadLatestFilms(){
    let res=await api.loadLatestFilms();
  
    let type={
      title:res.data.subject_collection.name,
      list:res.data.subject_collection_items,
      funName:"loadLatestFilms"
    };
    
    this.setData({
        "types[1]":type
    });
  }
  
})

